﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web4Comment
{
    public partial class manage : System.Web.UI.Page
    {
        public List<UnlessComment.Model.HotTopicInfo> list;
        private string username;

        protected void Page_Load(object sender, EventArgs e)
        {

            Session["username"] = "test";
            Session["user_id"] = 1;
            username = "test";

            if ((String)Session["username"] == null || (String)Session["username"] == "")
            {
                Response.Redirect("./logon.aspx");
            }

            if (!IsPostBack)
            {
                list = Web4Comment.Service.HotTopicService.getHotTopics(DateTime.Today);
            }
            else
            {
                if(today.Value == "0")
                    list = Web4Comment.Service.HotTopicService.getHotTopics(DateTime.Today);
                else
                    list = Web4Comment.Service.HotTopicService.getHotTopics(DateTime.Today);
            }
        }

        protected void hotTopicButton_Click(object sender, EventArgs e)
        {
            Web4Comment.Service.HotTopicService.addHotTopic(username, urlTextBox.Text, System.Int32.Parse(rankDropDownList.SelectedValue), addtionTextBox.Text);
        }

        protected void todayButton_Click(object sender, EventArgs e)
        {
            today.Value = "0";
        }

        protected void tomorrowButton_Click(object sender, EventArgs e)
        {
            today.Value = "1";
        }
    }
}